<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>查看当前时间</button>
    <div>时间</div>
</body>
<script>
    let btn = document.querySelector('button');
    let div = document.querySelector('div');
    btn.onclick = function(){
        div.innerText = new Date();
    }
</script>
</html>